/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package viewControl;

import entity.Laerer;
import org.hibernate.Session;

/**
 *
 * @author Morten Bormeth
 */
public class TeacherGUI extends javax.swing.JFrame {

    private Session session;
    private boolean rdy;
    private TrinmaalPanel tmp;
    private ElevPanel ep;
    private PotentialPanel pp;
    private KontaktPanel kp;
    private HandleplanPanel hpp;
    private Laerer currentLaerer;

    /**
     * Creates new form TeacherGUI
     */
    public TeacherGUI(Session session, Laerer l) {
        this.session = session;
        this.currentLaerer = l;
        rdy = false;
        initComponents();

        //Indsæt TrinmaalPanel
        tmp = new TrinmaalPanel(session, currentLaerer);
        trinmaalPanel.add(tmp);
        trinmaalPanel.validate();
        tmp.update();
        tmp.setBounds(0, 0, trinmaalPanel.getWidth(), trinmaalPanel.getHeight());

        //Indsæt ElevPanel
        ep = new ElevPanel(session, currentLaerer);
        elevPanel.add(ep);
        elevPanel.validate();
        ep.update();
        ep.setBounds(0, 0, elevPanel.getWidth(), elevPanel.getHeight());
        ep.limitPanel();

        //Indsæt PotentialePanel
        pp = new PotentialPanel(session, currentLaerer);
        potkompPanel.add(pp);
        potkompPanel.validate();
        pp.update();
        pp.setBounds(0, 0, potkompPanel.getWidth(), potkompPanel.getHeight());

        //Indsæt KontaktPanel
        kp = new KontaktPanel(session, currentLaerer);
        kontaktpersonPanel.add(kp);
        kontaktpersonPanel.validate();
        kp.update();
        kp.setBounds(0, 0, kontaktpersonPanel.getWidth(), kontaktpersonPanel.getHeight());
        kp.limitPanel();

        //Indsæt HandleplanPanel
        hpp = new HandleplanPanel(session, currentLaerer);
        handleplanOgEvalueringPanel.add(hpp);
        handleplanOgEvalueringPanel.validate();
        hpp.update();
        hpp.setBounds(0, 0, handleplanOgEvalueringPanel.getWidth(), handleplanOgEvalueringPanel.getHeight());

        setLocationRelativeTo(null);
        rdy = true;
        
        super.setTitle("Logget ind som Lærer - " + currentLaerer.toString());
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        tpTeacher = new javax.swing.JTabbedPane();
        elevPanel = new javax.swing.JPanel();
        kontaktpersonPanel = new javax.swing.JPanel();
        trinmaalPanel = new javax.swing.JPanel();
        potentialePanel = new javax.swing.JPanel();
        potkompPanel = new javax.swing.JPanel();
        handleplanOgEvalueringPanel = new javax.swing.JPanel();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

        tpTeacher.setMinimumSize(new java.awt.Dimension(144, 92));
        tpTeacher.setName("");
        tpTeacher.setPreferredSize(new java.awt.Dimension(986, 741));
        tpTeacher.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                tpTeacherStateChanged(evt);
            }
        });

        elevPanel.setLayout(null);
        tpTeacher.addTab("Elev", elevPanel);

        kontaktpersonPanel.setLayout(null);
        tpTeacher.addTab("Kontaktperson", kontaktpersonPanel);

        javax.swing.GroupLayout trinmaalPanelLayout = new javax.swing.GroupLayout(trinmaalPanel);
        trinmaalPanel.setLayout(trinmaalPanelLayout);
        trinmaalPanelLayout.setHorizontalGroup(
            trinmaalPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 981, Short.MAX_VALUE)
        );
        trinmaalPanelLayout.setVerticalGroup(
            trinmaalPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 713, Short.MAX_VALUE)
        );

        tpTeacher.addTab("Trinmål", trinmaalPanel);

        potentialePanel.setLayout(null);

        javax.swing.GroupLayout potkompPanelLayout = new javax.swing.GroupLayout(potkompPanel);
        potkompPanel.setLayout(potkompPanelLayout);
        potkompPanelLayout.setHorizontalGroup(
            potkompPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 900, Short.MAX_VALUE)
        );
        potkompPanelLayout.setVerticalGroup(
            potkompPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 660, Short.MAX_VALUE)
        );

        potentialePanel.add(potkompPanel);
        potkompPanel.setBounds(0, 0, 900, 660);

        tpTeacher.addTab("Potentiale og kompetencer", potentialePanel);

        handleplanOgEvalueringPanel.setLayout(null);
        tpTeacher.addTab("Handleplan og evaluering", handleplanOgEvalueringPanel);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(tpTeacher, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGap(0, 0, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(tpTeacher, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGap(0, 0, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void tpTeacherStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_tpTeacherStateChanged
        if (rdy) {
            tmp.update();
            ep.update();
            pp.update();
            kp.update();
        }
    }//GEN-LAST:event_tpTeacherStateChanged
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JPanel elevPanel;
    private javax.swing.JPanel handleplanOgEvalueringPanel;
    private javax.swing.JPanel kontaktpersonPanel;
    private javax.swing.JPanel potentialePanel;
    private javax.swing.JPanel potkompPanel;
    private javax.swing.JTabbedPane tpTeacher;
    private javax.swing.JPanel trinmaalPanel;
    // End of variables declaration//GEN-END:variables
}
